from typing import List
from pydantic import BaseModel, HttpUrl, Field


class ImageData(BaseModel):
    """
    定义单个图片的数据模型
    """
    image_url: str  # 图片地址，使用HttpUrl确保它是一个有效的URL
    transition_time: float = 0.7  # 转场时间，默认为0.7秒
    duration: int  # 持续时间，必须提供
    effect: str  # 转场效果，必须提供

    class Config:
        json_schema_extra = {
            "example": {
                "image_url": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image1.jpg",
                "transition_time": 0.7,
                "duration": 2,
                "effect": "fade"
            }
        }


class AudioWithImages(BaseModel):
    """
    定义音频与图片列表的数据模型
    """
    audio_url: str = "" # 音频地址,可以为空
    image_list_data: List[ImageData]  # 图片数据列表

    class Config:
        json_schema_extra = {
            "example": {
                "audio_url": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/output_audio.mp3",
                "image_list_data": [
                    {
                        "image_url": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image1.jpg",
                        "transition_time": 0.7,
                        "duration": 2,
                        "effect": "fade"
                    },
                    {
                        "image_url": "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image2.jpg",
                        "transition_time": 0.7,
                        "duration": 3,
                        "effect": "wipeup"
                    }
                ]
            }
        }


class SlideItem(BaseModel):
    '''
        # Models需要下面的信息
    transition_effect = "wiperight"
    transition_duration = 0.7
    audio_path = "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/output_audio.mp3"
    images_paths_urls = [
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image1.jpg",
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image2.jpg",
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image3.jpg"
    ]
    '''

    transition_effect: str = Field("wiperight", description="转场效果")
    transition_duration: float = Field(0.7, description="转场时间")
    audio_path: str = Field("https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/output_audio.mp3", description="音频地址")
    images_paths_urls: list = Field([
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image1.jpg",
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image2.jpg",
        "https://ty-huanlian.oss-cn-shanghai.aliyuncs.com/test/image3.jpg"
    ], description="图片地址列表")
